package com.rj.bd.service;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.rj.bd.dao.DingdanMapper;
import com.rj.bd.entity.Dingdan;
/**
 * 
 * @author 
 *
 */
@Service
public class DingdanServiceImpl implements IDingdanService{

	@Autowired
	public DingdanMapper dingdanMapper;
	
	@Override
	public List<Dingdan> queryAll() {
		return dingdanMapper.queryAll();
	}

	@Override
	public List<Map> getPage(Map maps, String did) {
		System.out.println("pageNo:"+maps.get("pageNo")+"\t"+"pageSize:"+maps.get("pageSize")+"\t"+"did:"+did);
        int pageNo=maps.get("pageNo")==null?1:Integer.valueOf(maps.get("pageNo")+"");
        int pageSize=maps.get("pageSize")==null?5:Integer.valueOf(maps.get("pageSize")+"");
        did= (String) maps.get("did");
        if (did == null) {
        	did = "";
        }
        maps.put("did","%"+did+"%");
        maps.put("start",(pageNo-1)*pageSize);
        maps.put("end",pageSize);
        	
        return dingdanMapper.getPage(maps);
	}

	@Override
	public List<Dingdan> query(String did) {
		 if (did == null) {
			 did = "";
	     }
		 
	  return dingdanMapper.query("%"+did+"%");
		
	}

	@Override
	public List<Map> getPageByUser(Map maps, String did, String uid) {
		System.out.println("pageNo:"+maps.get("pageNo")+"\t"+"pageSize:"+maps.get("pageSize")+"\t"+"did:"+did+"\t"+"uid:"+uid);
        int pageNo=maps.get("pageNo")==null?1:Integer.valueOf(maps.get("pageNo")+"");
        int pageSize=maps.get("pageSize")==null?5:Integer.valueOf(maps.get("pageSize")+"");
        did= (String) maps.get("did");
        uid= (String) maps.get("uid");
        if (did == null) {
        	did = "";
        }
        maps.put("did","%"+did+"%");
        maps.put("uid",uid);
        maps.put("start",(pageNo-1)*pageSize);
        maps.put("end",pageSize);
        	
        return dingdanMapper.getPageByUser(maps);
	}

	@Override
	public List<Map> queryByUser(Map maps,String did, String uid) {
		System.out.println("did:"+did+"\t"+"uid:"+uid);
        did= (String) maps.get("did");
        uid= (String) maps.get("uid");
        if (did == null) {
        	did = "";
        }
        maps.put("did","%"+did+"%");
        maps.put("uid",uid);
	  return dingdanMapper.queryByUser(maps);
	}

	@Override
	public void add(Dingdan dingdan) {
		dingdanMapper.add(dingdan);
	}

	@Override
	public List<Dingdan> queryByZhuangtai(String uid) {
		return dingdanMapper.queryByZhuangtai(uid);
	}

	@Override
	public void editByUserZhuangtai(String uid) {
		dingdanMapper.editByUserZhuangtai(uid);
	}

	@Override
	public void editByDingdanZhuangTaiWei(String bid) {
		dingdanMapper.editByDingdanZhuangTaiWei(bid);
	}

	


	

}
